#pragma once
#include "XInputManager.h"
#include "Input.h"


class GameState
{
public:
	virtual ~GameState() {}
	virtual void Init()	=0;
	virtual bool Update() {return true;}
	virtual void Render()=0;
	virtual void Exit(){};

	virtual const char* Name()
	{
		return "No label defined";
	}
};

class GameStateManager
{	
public:

	GameStateManager();

	int LastUpdateTime; // time of last update in milliseconds

	void Init();


	void SetGameState(GameState* NewState);

	bool Update();

	void Render();

	void Exit();

	GameState* GetCurrentState()
	{
		return TheGameState;
	}

private:

	void Reset();

	GameState* TheGameState;
	GameState* TheNextGameState;

};

class TheGameStateManager
{
public:

	static GameStateManager& Get()
	{
		if(!pGameStateManager)
		{
			pGameStateManager = new GameStateManager();

		}

		return *pGameStateManager;
	}

	static void Kill()
	{
		if(pGameStateManager)
		{
			pGameStateManager->Exit();
			delete pGameStateManager;
		}
	}

private:

	static GameStateManager* pGameStateManager;
};